package cn.gcjxsc.config;

import cn.gcjxsc.filter.MerchantPreFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * @author pumbaa
 * @since 1.0
 */
@Configuration
public class WebConfig extends WebMvcConfigurerAdapter {
    @Autowired
    private MerchantPreFilter merchantPreFilter;

    @Bean
    public FilterRegistrationBean merchantFilter() {
        FilterRegistrationBean bean = new FilterRegistrationBean();
        bean.setFilter(merchantPreFilter);
        List<String> urlPatterns = new ArrayList<>();
        urlPatterns.add("/merchant/*");
        bean.setUrlPatterns(urlPatterns);
        return bean;
    }
}
